#include "DatabaseManager.h"
#include <iostream>

DatabaseManager::DatabaseManager() {
    connection = MySQLConnectionPool::getInstance()->getConnection();
}

DatabaseManager::~DatabaseManager() {
    // Connection will be automatically returned to pool when shared_ptr is destroyed
}

bool DatabaseManager::execute(const std::string& sql) {
    if (!connection) {
        return false;
    }
    
    return connection->execute(sql);
}

bool DatabaseManager::executeQuery(const std::string& sql) {
    if (!connection) {
        return false;
    }
    
    return connection->executeQuery(sql);
}

char* DatabaseManager::getField(const std::string& fieldName) {
    if (!connection) {
        return nullptr;
    }
    
    return connection->getField(fieldName);
}